package cn.liip.dao;

import java.util.ArrayList;
import java.util.List;

import cn.liip.beans.Student;
import cn.liip.util.MySqlUtil;

public class ManageDaoMySqlImpl implements IManageDao {
	MySqlUtil db = new MySqlUtil();

	// 取所有名单
	@Override
	public List getAllStudent() {
		List<Student> studentList = new ArrayList<Student>();
		studentList = db.findAll();
		return studentList;
	}
	// 添加学生

	@Override
	public void add(Student student) {
		try {
			db.addOne(student);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	// 查找学生信息

	@Override
	public Student findOne(String _id) {
		Student student = new Student();
		student = db.findOne(_id);
		return student;
	}

	// 删除学生
	@Override
	public int del(String _id) {
		int result = -1;
		result = db.deleteOne(_id);
		return result;
	}

	// 更新学生信息
	@Override
	public int update(Student student) {
		int result = -1;
		result = db.update(student);
		return result;
	}

}
